In the event of technical difficulties with Szkopuł, please contact us via email at szkopul@fri.edu.pl.
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Professor Byteman Laugh has been given a unique chance. He has been told that he could get a million dollars for his research from Foundation for Helping Wicked Byteprofessors. The professor always does his best to make his research interesting. Now it is time for the society to grade the professor's work.
However, it is not so easy. The professor has only one week before he will have to present the results of his research. As every scientist, professor Laugh is a little bit absent-minded. He has lost the results somewhere, so he is asking you to write a program which reproduces them.
Professor Laugh does not like to bore his friends and colleagues. Therefore, he is not interested in ordinary integrals, but in thrilling and mind-blowing prime numbers.
For a prime number1
greater than
, an integer
greater than 1 and an integer
less than
the professor says that
is
-interesting if there is a natural number
such that,
In other words
and
give the same remainder when divided by
.
Write a program which:
The first line contains two integers separated by a single space: a prime number
and a number
(
). The second line contains
one integer
, i.e. the number of cases (
).
Each of next
lines contains one integer. The
-th of these lines
contains a number
,
.
Your program should write exactly lines. The line number
(
) should
contain one word: TAK (i.e. yes in Polish) if
is
-interesting,
NIE (i.e. no in Polish) if it is not.
For the input data:
17 2 5 1 9 3 7 6
the correct result is:
TAK TAK NIE NIE NIE
Task authors: Jakub Pawlewicz, Jakub Radoszewski (formulation by Szymon Wasik).